<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" charset="utf-8">
		<title></title>
	</head>
	<body>
		 <div id='info'>
			<div id="">
				<div class="imgdiv"><img src="./img/cityloading.png" ></div>
				<div id="city">正在获取您当前的位置...</div>
			</div>
		</div>
		<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=089ca4e7a8497eb5b123ecfdb70b68e3&plugin=AMap.CitySearch"></script>
		<script type="text/javascript">
				document.addEventListener('DOMContentLoaded',function(){
					//获取用户所在城市信息
					function showCityInfo() {
						//实例化城市查询类
						var citysearch = new AMap.CitySearch();
						//自动获取用户IP，返回当前城市
						citysearch.getLocalCity(function(status, result) {
							console.log(result)
							if(status === 'complete' && result.info === 'OK'){
								console.log(result.city)
								//城市存到本地
								localStorage.setItem('cityLocation', result.city);
							}
						});
					}
					showCityInfo();
				},false)
			</script>
	</body>
</html>
